﻿using System;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using System.IO;
using System.Windows.Threading;
using System.Threading;
using System.Data;
using System.Xml.Serialization;


namespace MediaPlayer_Beta
{
	/// <summary>
	/// Logique d'interaction pour Window1.xaml
	/// </summary>
	public partial class Window1 : Window
	{

        public List<Ressource> Lect;
        List<playlist> playls;
        ListBox listbo;

        public Window1(List<Ressource> Pl, List<playlist> playlists, ListBox Listb)
        {
		    this.InitializeComponent();
            Lect = Pl;
            playls = playlists;
            listbo = Listb;
            foreach (playlist list in playls)
            {
                ListPlaylist.Items.Add(list.name);
            }
		// Insérez le code requis pour la création d’objet sous ce point.
		}

        private void ListListChanged(object sender, RoutedEventArgs e)
        {
            if (ListPlaylist.SelectedIndex != -1)
            {
                ListElementPlaylist.Items.Clear();
                foreach (Ressource Elem in playls[ListPlaylist.SelectedIndex].pl)
                {
                    ListElementPlaylist.Items.Add(Elem.name);
                }
            }
        }

        private void ListBoxItem_MouseDoubleClick(object sender, RoutedEventArgs e)
        {
            if (ListPlaylist.SelectedIndex != -1)
            {
                int count = playls[ListPlaylist.SelectedIndex].pl.Count;
                for (int j = 0; j < count; j++)
                    Lect.Add(playls[ListPlaylist.SelectedIndex].pl[j]);
                for (int i = 0; i < count; i++)
                    listbo.Items.Add(playls[ListPlaylist.SelectedIndex].pl[i].name);

                this.Close();
            }
        }
	}
}